﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ComputerStoreManager.View;
using ComputerStoreManager.ViewModel;

namespace ComputerStoreManager {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    //public delegate void OnMainWinDowExitEventHandler();
    public partial class MainWindow : Window {
        private static MainWindow _instance;

        private static object syncLock = new object();

        public static MainWindow GetInstance() {
            if(_instance == null) {
                lock(syncLock) {
                    if(_instance == null) {
                        _instance = new MainWindow();
                    }
                }
            }
            return _instance;
        }
        protected MainWindow() {
            InitializeComponent();
            this.LayoutRoot.Children.Add(new ManagerWindow());
            //Closed += MainWindow_Closed;
            Closing += MainWindow_Closing;
        }

        //public event OnMainWinDowExitEventHandler OnMainWinDowExitClicked;
        void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
            e.Cancel = true;
            this.Hide();
            LoginPanel.GetInstance().Show();
        }

    }
}
